// **************************************************************
// Com ++ Framework by the C++ World
// Please report defects: mailto:compp@cplusplusworld.com
// Please visit: http://www.cplusplusworld.com/socketlibrary.html
// **************************************************************

#include <iostream>
#include <cstdlib>

#include "SysPlusPlus/SysPlusPlus"
#include "ComPlusPlus/ComPlusPlus"


int main ( int argc, char *argv [] ) {

  if ( argc != 3 ) {
    std::cout << "Usage: " << argv [0] << " IP-ADDR Port\n";	
  	exit(1);
  }
  	
  int CPort = std::atoi ( argv[2] );	
  char buf [10000 ];
  std::memset( (void*)buf, 0, sizeof ( buf ) );

try {	
  compp::SocketUdp Srv;
  Srv.SetSockOptReuseAddress ( true);
  Srv.SetSockOptBroadcast ( true);

  Srv.Bind( argv[1], CPort );	

  Srv.Recv(buf, sizeof(buf),0);
  std::cout << "---" << buf << "---\n";

} catch ( syspp::ComException e ) {
  std::cout << "Exception " << e.what( ) << "\n" ;	
	
}  	
  return 0;
}
